package com.alks.function.controller.finance.fincons;

import com.alks.common.aop.ApiRestController;
import com.alks.common.aop.RoleCheck;
import com.alks.common.aop.WebLogger;
import com.alks.entity.data.response.ResponseInfo;
import com.alks.function.data.request.finance.fincons.CostDetailsRequest;
import com.alks.function.service.finance.fincons.CostSttlementService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@Slf4j
@Api(value = "财务部-工厂-财务咨询查询", tags = {"财务部-费用结算查询"})
@ApiRestController("/CostSttlement")
@RoleCheck(prgIds = {"100502","180502"})
public class CostSttlementController {

    @Autowired
    private CostSttlementService costSttlementService;

    @WebLogger
    @PostMapping("/getCostDetailsList")
    @ApiOperation(value = "费用明细查询",tags = "财务部-费用结算查询")
    public ResponseInfo getCostDetailsList(@RequestBody CostDetailsRequest request){
        return costSttlementService.getCostDetailsList(request);
    }

    @WebLogger
    @PostMapping("/getCount")
    @ApiOperation(value = "数量统计",tags = "财务部-费用结算查询")
    public ResponseInfo getCount(@RequestBody List<Integer> ids){
        return costSttlementService.getCount(ids);
    }

    @WebLogger
    @GetMapping("/deleteCostDetailsById")
    @ApiOperation(value = "删除费用明细",tags = "财务部-费用结算查询")
    public ResponseInfo deleteCostDetailsById(@RequestParam Integer id){
        return costSttlementService.deleteCostDetailsById(id);
    }

    @WebLogger
    @PostMapping("/exportCostDetails")
    @ApiOperation(value = "导出",tags = "财务部-费用结算查询")
    public void exportCostDetails(@RequestBody List<Integer> ids, HttpServletResponse response) throws IOException {
        costSttlementService.exportCostDetails(ids,response);
    }

}
